Load all required libraries.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.8
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(broom)
Read in raw data from RDS.
raw_data <- readRDS("./n1_n2_cleaned_cases.rds")
Make a few small modifications to names and data for visualizations.
final_data <- raw_data %>% mutate(log_copy_per_L = log10(mean_copy_num_L)) %>%
rename(Facility = wrf) %>%
mutate(Facility = recode(Facility,
"NO" = "WRF A",
"MI" = "WRF B",
"CC" = "WRF C"))
Seperate the data by gene target to ease layering in the final plot
#make three data layers
only_positives <<- subset(final_data, (!is.na(final_data$Facility)))
only_n1 <- subset(only_positives, target == "N1")
only_n2 <- subset(only_positives, target == "N2")
only_background <<-final_data %>%
select(c(date, cases_cum_clarke, new_cases_clarke, X7_day_ave_clarke)) %>%
group_by(date) %>% summarise_if(is.numeric, mean)
#specify fun colors
background_color <- "#7570B3"
seven_day_ave_color <- "#E6AB02"
marker_colors <- c("N1" = '#1B9E77',"N2" ='#D95F02')
#remove facilty C for now
#only_n1 <- only_n1[!(only_n1$Facility == "WRF C"),]
#only_n2 <- only_n2[!(only_n2$Facility == "WRF C"),]
only_n1 <- only_n1[!(only_n1$Facility == "WRF A" & only_n1$date == "2020-11-02"), ]
only_n2 <- only_n2[!(only_n2$Facility == "WRF A" & only_n2$date == "2020-11-02"), ]
Build the main plot
#first layer is the background epidemic curve
p1 <- only_background %>%
plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~new_cases_clarke,
type = "bar",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Daily Cases: ', new_cases_clarke),
alpha = 0.5,
name = "Daily Reported Cases",
color = background_color,
colors = background_color,
showlegend = FALSE) %>%
layout(yaxis = list(title = "Clarke County Daily Cases", showline=TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#renders the main plot layer two as seven day moving average
p1 <- p1 %>% plotly::add_trace(x = ~date, y = ~X7_day_ave_clarke,
type = "scatter",
mode = "lines",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Seven-Day Moving Average: ', X7_day_ave_clarke),
name = "Seven Day Moving Average Athens",
line = list(color = seven_day_ave_color),
showlegend = FALSE)
#renders the main plot layer three as positive target hits
p2 <- plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n1,
symbol = ~Facility,
marker = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n2,
symbol = ~Facility,
marker = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(yaxis = list(title = "SARS CoV-2 Copies/L",
showline = TRUE,
type = "log",
dtick = 1,
automargin = TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#adds the limit of detection dashed line
p2 <- p2 %>% plotly::add_segments(x = as.Date("2020-03-14"),
xend = ~max(date + 10),
y = 3571.429, yend = 3571.429,
opacity = 0.35,
line = list(color = "black", dash = "dash")) %>%
layout(annotations = list(x = as.Date("2020-03-28"), y = 3.8, xref = "x", yref = "y",
text = "Limit of Detection", showarrow = FALSE))
p1
p2
Combine the two main plot pieces as a subplot
#seperate n1 and n2 frames by site
#n1
wrf_a_only_n1 <- subset(only_n1, Facility == "WRF A")
wrf_b_only_n1 <- subset(only_n1, Facility == "WRF B")
wrf_c_only_n1 <- subset(only_n1, Facility == "WRF C")
#n2
wrf_a_only_n2 <- subset(only_n2, Facility == "WRF A")
wrf_b_only_n2 <- subset(only_n2, Facility == "WRF B")
wrf_c_only_n2 <- subset(only_n2, Facility == "WRF C")
#rejoin the old data frames then seperate in to averages for each plant.
wrfa_both <- full_join(wrf_a_only_n1, wrf_a_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
wrfb_both <- full_join(wrf_b_only_n1, wrf_b_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
wrfc_both <- full_join(wrf_c_only_n1, wrf_c_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
#get max date
maxdate <- max(wrfa_both$date)
mindate <- min(wrfa_both$date)
Build loess smoothing figures figures
This makes the individual plots
#**************************************WRF A PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_botha <- ggplot(wrfa_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_botha<<-..y..), method = "loess", color = '#1B9E77',
span = 0.25, n = 842)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_botha
## `geom_smooth()` using formula 'y ~ x'
fit_botha
## [1] 13.04902 13.04431 13.03965 13.03505 13.03050 13.02601 13.02157 13.01718
## [9] 13.01284 13.00855 13.00432 13.00013 12.99600 12.99191 12.98788 12.98389
## [17] 12.97995 12.97606 12.97222 12.96843 12.96468 12.96099 12.95733 12.95373
## [25] 12.95017 12.94665 12.94318 12.93975 12.93637 12.93303 12.92974 12.92649
## [33] 12.92328 12.92011 12.91699 12.91391 12.91087 12.90786 12.90490 12.90198
## [41] 12.89910 12.89626 12.89346 12.89071 12.88801 12.88538 12.88281 12.88029
## [49] 12.87784 12.87545 12.87311 12.87084 12.86862 12.86647 12.86438 12.86234
## [57] 12.86036 12.85845 12.85659 12.85480 12.85306 12.85138 12.84976 12.84821
## [65] 12.84671 12.84527 12.84389 12.84257 12.84131 12.84011 12.83896 12.83788
## [73] 12.83686 12.83589 12.83499 12.83415 12.83336 12.83263 12.83197 12.83136
## [81] 12.83081 12.83032 12.82989 12.82952 12.82920 12.82895 12.82876 12.82862
## [89] 12.82855 12.82853 12.82857 12.82867 12.82883 12.82903 12.82929 12.82960
## [97] 12.82995 12.83036 12.83082 12.83133 12.83189 12.83250 12.83316 12.83387
## [105] 12.83463 12.83544 12.83631 12.83722 12.83819 12.83921 12.84027 12.84139
## [113] 12.84256 12.84378 12.84506 12.84638 12.84776 12.84918 12.85066 12.85219
## [121] 12.85377 12.85540 12.85709 12.85883 12.86061 12.86245 12.86435 12.86629
## [129] 12.86829 12.87033 12.87243 12.87458 12.87679 12.87904 12.88135 12.88457
## [137] 12.88943 12.89576 12.90341 12.91220 12.92196 12.93252 12.94371 12.95537
## [145] 12.96732 12.97941 12.99145 13.00328 13.01474 13.02565 13.03584 13.04514
## [153] 13.05340 13.06043 13.06607 13.07015 13.07399 13.07894 13.08494 13.09188
## [161] 13.09970 13.10830 13.11760 13.12751 13.13796 13.14886 13.16011 13.17165
## [169] 13.18339 13.19523 13.20710 13.21892 13.23059 13.24204 13.25317 13.26391
## [177] 13.27418 13.28388 13.29293 13.30126 13.30876 13.31537 13.32100 13.32555
## [185] 13.32896 13.33113 13.33198 13.33142 13.32937 13.32611 13.32199 13.31705
## [193] 13.31133 13.30486 13.29769 13.28984 13.28137 13.27231 13.26269 13.25256
## [201] 13.24195 13.23090 13.21945 13.20764 13.19551 13.18309 13.17042 13.15755
## [209] 13.14450 13.13132 13.11805 13.10472 13.09137 13.07804 13.06477 13.05160
## [217] 13.03857 13.02421 13.00719 12.98776 12.96615 12.94260 12.91734 12.89063
## [225] 12.86268 12.83375 12.80406 12.77386 12.74338 12.71286 12.68255 12.65267
## [233] 12.62346 12.59517 12.56802 12.54227 12.51814 12.49587 12.47571 12.45788
## [241] 12.44088 12.42311 12.40465 12.38560 12.36605 12.34609 12.32581 12.30531
## [249] 12.28468 12.26400 12.24338 12.22290 12.20266 12.18275 12.16325 12.14427
## [257] 12.12589 12.10821 12.09132 12.07531 12.06026 12.04639 12.03375 12.02227
## [265] 12.01185 12.00241 11.99386 11.98612 11.97909 11.97270 11.96685 11.96146
## [273] 11.95644 11.95171 11.94718 11.94276 11.93836 11.93390 11.92930 11.92446
## [281] 11.91930 11.91373 11.90767 11.90103 11.89372 11.88565 11.87675 11.86743
## [289] 11.85820 11.84906 11.84000 11.83102 11.82214 11.81334 11.80463 11.79601
## [297] 11.78748 11.77904 11.77069 11.76244 11.75428 11.74621 11.73824 11.73036
## [305] 11.72258 11.71490 11.70731 11.69983 11.69244 11.68516 11.67720 11.66789
## [313] 11.65736 11.64573 11.63315 11.61973 11.60561 11.59091 11.57578 11.56034
## [321] 11.54471 11.52904 11.51345 11.49807 11.48303 11.46846 11.45449 11.44126
## [329] 11.42889 11.41752 11.40726 11.39827 11.39065 11.38456 11.38010 11.37743
## [337] 11.37666 11.37656 11.37589 11.37476 11.37330 11.37162 11.36983 11.36806
## [345] 11.36643 11.36504 11.36402 11.36348 11.36355 11.36433 11.36596 11.36853
## [353] 11.37218 11.37702 11.38317 11.39074 11.39985 11.41126 11.42553 11.44245
## [361] 11.46184 11.48350 11.50722 11.53281 11.56007 11.58882 11.61884 11.64995
## [369] 11.68194 11.71463 11.74780 11.78128 11.81485 11.84833 11.88151 11.91421
## [377] 11.94621 11.97733 12.00737 12.03614 12.06342 12.08904 12.11279 12.13447
## [385] 12.15389 12.17369 12.19642 12.22174 12.24932 12.27882 12.30990 12.34222
## [393] 12.37545 12.40926 12.44330 12.47723 12.51073 12.54346 12.57507 12.60523
## [401] 12.63361 12.65986 12.68366 12.70466 12.72252 12.73692 12.74919 12.76092
## [409] 12.77210 12.78275 12.79286 12.80246 12.81154 12.82010 12.82817 12.83574
## [417] 12.84282 12.84941 12.85553 12.86117 12.86636 12.87108 12.87535 12.87918
## [425] 12.88257 12.88553 12.88806 12.89017 12.89188 12.89192 12.88921 12.88401
## [433] 12.87658 12.86716 12.85601 12.84338 12.82953 12.81472 12.79918 12.78319
## [441] 12.76699 12.75084 12.73499 12.71969 12.70520 12.69177 12.67966 12.66912
## [449] 12.66040 12.65377 12.64720 12.63863 12.62824 12.61619 12.60265 12.58779
## [457] 12.57176 12.55475 12.53692 12.51844 12.49946 12.48017 12.46073 12.44131
## [465] 12.42207 12.40319 12.38482 12.36714 12.35032 12.33452 12.31991 12.30666
## [473] 12.29493 12.28490 12.27673 12.27059 12.26540 12.25999 12.25443 12.24875
## [481] 12.24301 12.23725 12.23153 12.22588 12.22037 12.21504 12.20994 12.20511
## [489] 12.20061 12.19648 12.19278 12.18955 12.18684 12.18470 12.18317 12.18231
## [497] 12.18217 12.18280 12.18423 12.18731 12.19271 12.20026 12.20979 12.22112
## [505] 12.23407 12.24848 12.26417 12.28097 12.29869 12.31717 12.33624 12.35571
## [513] 12.37542 12.39519 12.41485 12.43422 12.45312 12.47139 12.48885 12.50533
## [521] 12.52065 12.53464 12.54712 12.55792 12.56687 12.57379 12.57850 12.58256
## [529] 12.58755 12.59337 12.59993 12.60714 12.61489 12.62309 12.63164 12.64045
## [537] 12.64941 12.65843 12.66742 12.67628 12.68490 12.69320 12.70107 12.70842
## [545] 12.71515 12.72117 12.72638 12.73068 12.73397 12.73616 12.73715 12.73685
## [553] 12.73515 12.73196 12.72718 12.72055 12.71193 12.70149 12.68937 12.67571
## [561] 12.66066 12.64437 12.62698 12.60864 12.58949 12.56969 12.54938 12.52870
## [569] 12.50780 12.48683 12.46593 12.44525 12.42494 12.40514 12.38599 12.36766
## [577] 12.35027 12.33398 12.31893 12.30528 12.29316 12.28049 12.26527 12.24774
## [585] 12.22815 12.20675 12.18379 12.15952 12.13419 12.10804 12.08134 12.05432
## [593] 12.02723 12.00033 11.97387 11.94809 11.92324 11.89958 11.87734 11.85679
## [601] 11.83817 11.82173 11.80772 11.79639 11.78626 11.77575 11.76490 11.75380
## [609] 11.74251 11.73109 11.71962 11.70816 11.69678 11.68555 11.67453 11.66379
## [617] 11.65340 11.64343 11.63394 11.62500 11.61668 11.60905 11.60217 11.59611
## [625] 11.59094 11.58673 11.58354 11.58143 11.58049 11.58077 11.58302 11.58777
## [633] 11.59482 11.60395 11.61494 11.62757 11.64164 11.65691 11.67319 11.69024
## [641] 11.70786 11.72582 11.74392 11.76193 11.77964 11.79684 11.81330 11.82881
## [649] 11.84315 11.85611 11.86747 11.87876 11.89157 11.90579 11.92131 11.93801
## [657] 11.95578 11.97451 11.99408 12.01439 12.03531 12.05675 12.07858 12.10069
## [665] 12.12297 12.14530 12.16758 12.18970 12.21153 12.23296 12.25389 12.27420
## [673] 12.29378 12.31251 12.33028 12.34699 12.36251 12.37673 12.38955 12.40172
## [681] 12.41404 12.42650 12.43905 12.45166 12.46430 12.47694 12.48953 12.50206
## [689] 12.51448 12.52676 12.53887 12.55077 12.56244 12.57384 12.58493 12.59568
## [697] 12.60606 12.61604 12.62558 12.63464 12.64321 12.65123 12.65871 12.66566
## [705] 12.67213 12.67814 12.68373 12.68892 12.69376 12.69826 12.70247 12.70642
## [713] 12.71013 12.71364 12.71698 12.72019 12.72329 12.72632 12.72931 12.73228
## [721] 12.73528 12.73834 12.74148 12.74474 12.74815 12.75174 12.75555 12.75960
## [729] 12.76364 12.76738 12.77085 12.77406 12.77702 12.77976 12.78229 12.78462
## [737] 12.78678 12.78878 12.79064 12.79237 12.79399 12.79552 12.79698 12.79837
## [745] 12.79972 12.80105 12.80236 12.80369 12.80503 12.80633 12.80749 12.80851
## [753] 12.80940 12.81016 12.81081 12.81133 12.81174 12.81203 12.81222 12.81230
## [761] 12.81228 12.81216 12.81195 12.81166 12.81127 12.81080 12.81026 12.80964
## [769] 12.80895 12.80819 12.80737 12.80648 12.80550 12.80437 12.80309 12.80169
## [777] 12.80017 12.79852 12.79676 12.79490 12.79295 12.79090 12.78877 12.78656
## [785] 12.78429 12.78195 12.77955 12.77711 12.77463 12.77211 12.76956 12.76699
## [793] 12.76441 12.76179 12.75910 12.75634 12.75350 12.75059 12.74761 12.74455
## [801] 12.74142 12.73821 12.73492 12.73156 12.72812 12.72460 12.72100 12.71733
## [809] 12.71357 12.70973 12.70581 12.70181 12.69772 12.69355 12.68930 12.68496
## [817] 12.68054 12.67603 12.67143 12.66675 12.66198 12.65712 12.65217 12.64714
## [825] 12.64202 12.63682 12.63153 12.62615 12.62069 12.61514 12.60952 12.60380
## [833] 12.59801 12.59213 12.58617 12.58013 12.57400 12.56779 12.56151 12.55514
## [841] 12.54869 12.54216
#assign fits to a vector
both_trenda <- fit_botha
#extract y min and max for each
limits_botha <- ggplot_build(extract_botha)$data
## `geom_smooth()` using formula 'y ~ x'
limits_botha <- as.data.frame(limits_botha)
both_ymina <- limits_botha$ymin
both_ymaxa <- limits_botha$ymax
#reassign dataframes (just to be safe)
work_botha <- wrfa_both
#fill in missing dates to smooth fits
work_botha <- work_botha %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_botha <- work_botha$date
#create a new smooth dataframe to layer
smooth_frame_botha <- data.frame(date_vec_botha, both_trenda, both_ymina, both_ymaxa)
#WRF A
#plot smooth frames
p_wrf_a <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_botha, y = ~both_trenda,
data = smooth_frame_botha,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha,
'</br> Median Log Copies: ', round(both_trenda, digits = 2)),
line = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_botha, ymin = ~both_ymina, ymax = ~both_ymaxa,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxa, digits = 2),
'</br> Min Log Copies: ', round(both_ymina, digits = 2)),
name = "",
fillcolor = '#1B9E77',
line = list(color = '#1B9E77')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF A") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfa_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#1B9E77', size = 6, opacity = 0.65))
p_wrf_a
save(p_wrf_a, file = "./plotly_objs/p_wrf_a.rda")
#**************************************WRF B PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothb <- ggplot(wrfb_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothb<<-..y..), method = "loess", color = '#D95F02',
span = 0.25, n = 842)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothb
## `geom_smooth()` using formula 'y ~ x'
fit_bothb
## [1] 12.60504 12.60118 12.59740 12.59370 12.59007 12.58652 12.58304 12.57964
## [9] 12.57632 12.57307 12.56990 12.56680 12.56378 12.56084 12.55797 12.55518
## [17] 12.55247 12.54983 12.54726 12.54478 12.54237 12.54004 12.53778 12.53560
## [25] 12.53350 12.53147 12.52952 12.52765 12.52586 12.52414 12.52250 12.52093
## [33] 12.51944 12.51803 12.51670 12.51544 12.51426 12.51316 12.51213 12.51119
## [41] 12.51031 12.50952 12.50880 12.50818 12.50765 12.50722 12.50689 12.50666
## [49] 12.50652 12.50648 12.50654 12.50668 12.50693 12.50726 12.50768 12.50820
## [57] 12.50881 12.50950 12.51028 12.51115 12.51211 12.51315 12.51428 12.51549
## [65] 12.51678 12.51816 12.51962 12.52116 12.52277 12.52447 12.52625 12.52810
## [73] 12.53003 12.53203 12.53411 12.53627 12.53849 12.54079 12.54316 12.54560
## [81] 12.54811 12.55069 12.55334 12.55605 12.55884 12.56168 12.56459 12.56757
## [89] 12.57061 12.57371 12.57687 12.58010 12.58351 12.58722 12.59123 12.59551
## [97] 12.60006 12.60486 12.60989 12.61515 12.62062 12.62629 12.63214 12.63816
## [105] 12.64434 12.65066 12.65711 12.66368 12.67035 12.67711 12.68395 12.69085
## [113] 12.69779 12.70478 12.71178 12.71880 12.72581 12.73280 12.73976 12.74667
## [121] 12.75353 12.76031 12.76701 12.77361 12.78010 12.78646 12.79268 12.79875
## [129] 12.80465 12.81038 12.81591 12.82123 12.82633 12.83189 12.83849 12.84602
## [137] 12.85438 12.86343 12.87308 12.88320 12.89367 12.90439 12.91523 12.92608
## [145] 12.93683 12.94736 12.95755 12.96729 12.97647 12.98496 12.99266 12.99945
## [153] 13.00521 13.00982 13.01472 13.02132 13.02947 13.03904 13.04987 13.06183
## [161] 13.07477 13.08856 13.10304 13.11808 13.13353 13.14925 13.16511 13.18094
## [169] 13.19662 13.21201 13.22695 13.24130 13.25493 13.26769 13.27943 13.29002
## [177] 13.29932 13.30717 13.31344 13.31799 13.32066 13.32133 13.32032 13.31808
## [185] 13.31469 13.31020 13.30466 13.29814 13.29069 13.28237 13.27325 13.26338
## [193] 13.25281 13.24162 13.22985 13.21757 13.20483 13.19169 13.17822 13.16446
## [201] 13.15049 13.13635 13.12211 13.10782 13.09354 13.07934 13.06527 13.05139
## [209] 13.03776 13.02443 13.01147 12.99894 12.98539 12.96950 12.95144 12.93141
## [217] 12.90960 12.88620 12.86140 12.83540 12.80837 12.78052 12.75204 12.72311
## [225] 12.69392 12.66468 12.63556 12.60676 12.57847 12.55088 12.52417 12.49856
## [233] 12.47421 12.45133 12.43010 12.41072 12.39337 12.37825 12.36424 12.35013
## [241] 12.33595 12.32172 12.30748 12.29324 12.27903 12.26489 12.25083 12.23690
## [249] 12.22311 12.20949 12.19607 12.18288 12.16994 12.15729 12.14494 12.13293
## [257] 12.12129 12.11004 12.09920 12.08949 12.08149 12.07504 12.07001 12.06624
## [265] 12.06358 12.06188 12.06101 12.06080 12.06111 12.06179 12.06269 12.06367
## [273] 12.06457 12.06525 12.06556 12.06535 12.06447 12.06278 12.06012 12.05634
## [281] 12.05131 12.04486 12.03802 12.03188 12.02638 12.02146 12.01706 12.01313
## [289] 12.00961 12.00644 12.00357 12.00093 11.99848 11.99614 11.99387 11.99161
## [297] 11.98931 11.98689 11.98431 11.98151 11.97844 11.97503 11.97122 11.96697
## [305] 11.96221 11.95688 11.95093 11.94431 11.93611 11.92566 11.91317 11.89887
## [313] 11.88299 11.86577 11.84742 11.82818 11.80827 11.78793 11.76738 11.74684
## [321] 11.72656 11.70676 11.68766 11.66949 11.65249 11.63687 11.62288 11.61073
## [329] 11.60066 11.59289 11.58766 11.58293 11.57666 11.56907 11.56036 11.55073
## [337] 11.54039 11.52955 11.51841 11.50719 11.49607 11.48528 11.47502 11.46549
## [345] 11.45691 11.44947 11.44338 11.43886 11.43610 11.43531 11.43671 11.44048
## [353] 11.44667 11.45504 11.46547 11.47781 11.49194 11.50770 11.52497 11.54360
## [361] 11.56345 11.58439 11.60628 11.62898 11.65236 11.67626 11.70057 11.72513
## [369] 11.74981 11.77447 11.79897 11.82318 11.84695 11.87015 11.89265 11.91429
## [377] 11.93495 11.95448 11.97275 11.98962 12.00709 12.02713 12.04952 12.07401
## [385] 12.10040 12.12847 12.15797 12.18870 12.22043 12.25294 12.28600 12.31939
## [393] 12.35288 12.38625 12.41929 12.45176 12.48344 12.51411 12.54355 12.57153
## [401] 12.59782 12.62221 12.64448 12.66439 12.68172 12.69626 12.70949 12.72301
## [409] 12.73674 12.75061 12.76453 12.77844 12.79226 12.80590 12.81930 12.83238
## [417] 12.84506 12.85726 12.86892 12.87994 12.89027 12.89981 12.90850 12.91625
## [425] 12.92300 12.92866 12.93316 12.93643 12.93838 12.93815 12.93511 12.92952
## [433] 12.92163 12.91170 12.89999 12.88676 12.87226 12.85676 12.84051 12.82377
## [441] 12.80680 12.78986 12.77320 12.75709 12.74178 12.72753 12.71460 12.70325
## [449] 12.69373 12.68631 12.67871 12.66863 12.65629 12.64189 12.62566 12.60779
## [457] 12.58850 12.56801 12.54653 12.52426 12.50141 12.47821 12.45486 12.43158
## [465] 12.40857 12.38605 12.36422 12.34331 12.32352 12.30506 12.28815 12.27300
## [473] 12.25982 12.24882 12.24021 12.23420 12.22936 12.22414 12.21860 12.21282
## [481] 12.20687 12.20082 12.19473 12.18867 12.18271 12.17692 12.17137 12.16613
## [489] 12.16126 12.15684 12.15293 12.14961 12.14693 12.14497 12.14380 12.14349
## [497] 12.14410 12.14570 12.14837 12.15288 12.15985 12.16910 12.18045 12.19373
## [505] 12.20875 12.22535 12.24333 12.26254 12.28278 12.30388 12.32566 12.34795
## [513] 12.37057 12.39334 12.41607 12.43861 12.46076 12.48235 12.50321 12.52315
## [521] 12.54200 12.55958 12.57571 12.59021 12.60292 12.61364 12.62221 12.63075
## [529] 12.64138 12.65393 12.66819 12.68399 12.70112 12.71941 12.73867 12.75869
## [537] 12.77931 12.80032 12.82154 12.84279 12.86386 12.88457 12.90474 12.92418
## [545] 12.94269 12.96009 12.97618 12.99079 13.00372 13.01478 13.02378 13.03054
## [553] 13.03486 13.03656 13.03545 13.03169 13.02567 13.01753 13.00745 12.99555
## [561] 12.98201 12.96698 12.95060 12.93303 12.91442 12.89492 12.87470 12.85390
## [569] 12.83267 12.81117 12.78955 12.76796 12.74656 12.72550 12.70493 12.68501
## [577] 12.66588 12.64771 12.63065 12.61484 12.60044 12.58502 12.56624 12.54444
## [585] 12.51993 12.49302 12.46404 12.43329 12.40111 12.36780 12.33369 12.29910
## [593] 12.26433 12.22972 12.19557 12.16221 12.12995 12.09911 12.07002 12.04298
## [601] 12.01832 11.99635 11.97739 11.96176 11.94734 11.93187 11.91547 11.89828
## [609] 11.88041 11.86200 11.84316 11.82403 11.80472 11.78537 11.76610 11.74703
## [617] 11.72829 11.71000 11.69230 11.67529 11.65912 11.64390 11.62977 11.61684
## [625] 11.60524 11.59509 11.58653 11.57968 11.57465 11.57159 11.57067 11.57192
## [633] 11.57516 11.58023 11.58694 11.59515 11.60468 11.61536 11.62703 11.63952
## [641] 11.65266 11.66628 11.68021 11.69430 11.70836 11.72224 11.73576 11.74876
## [649] 11.76107 11.77252 11.78295 11.79395 11.80712 11.82231 11.83936 11.85814
## [657] 11.87847 11.90021 11.92320 11.94730 11.97235 11.99819 12.02467 12.05164
## [665] 12.07895 12.10644 12.13395 12.16135 12.18846 12.21515 12.24125 12.26662
## [673] 12.29110 12.31453 12.33677 12.35766 12.37704 12.39477 12.41069 12.42593
## [681] 12.44169 12.45790 12.47450 12.49142 12.50861 12.52599 12.54351 12.56111
## [689] 12.57872 12.59628 12.61372 12.63099 12.64801 12.66473 12.68109 12.69702
## [697] 12.71245 12.72733 12.74160 12.75518 12.76802 12.78005 12.79144 12.80240
## [705] 12.81295 12.82311 12.83290 12.84234 12.85145 12.86025 12.86876 12.87701
## [713] 12.88500 12.89277 12.90033 12.90770 12.91490 12.92196 12.92889 12.93571
## [721] 12.94244 12.94910 12.95572 12.96231 12.96889 12.97549 12.98212 12.98881
## [729] 12.99555 13.00234 13.00915 13.01595 13.02271 13.02941 13.03602 13.04252
## [737] 13.04887 13.05505 13.06104 13.06680 13.07232 13.07756 13.08250 13.08712
## [745] 13.09137 13.09525 13.09872 13.10176 13.10433 13.10646 13.10820 13.10956
## [753] 13.11057 13.11124 13.11159 13.11166 13.11144 13.11098 13.11028 13.10937
## [761] 13.10826 13.10698 13.10555 13.10398 13.10230 13.10053 13.09869 13.09680
## [769] 13.09487 13.09293 13.09100 13.08910 13.08710 13.08487 13.08240 13.07972
## [777] 13.07682 13.07372 13.07043 13.06696 13.06331 13.05949 13.05551 13.05138
## [785] 13.04711 13.04270 13.03818 13.03353 13.02878 13.02393 13.01899 13.01396
## [793] 13.00887 13.00366 12.99831 12.99281 12.98715 12.98135 12.97539 12.96929
## [801] 12.96303 12.95662 12.95005 12.94334 12.93647 12.92945 12.92227 12.91494
## [809] 12.90746 12.89982 12.89203 12.88408 12.87598 12.86772 12.85930 12.85073
## [817] 12.84200 12.83312 12.82407 12.81487 12.80551 12.79601 12.78636 12.77657
## [825] 12.76665 12.75658 12.74637 12.73602 12.72552 12.71487 12.70409 12.69315
## [833] 12.68206 12.67083 12.65945 12.64791 12.63623 12.62439 12.61240 12.60025
## [841] 12.58795 12.57549
#assign fits to a vector
both_trendb <- fit_bothb
#extract y min and max for each
limits_bothb <- ggplot_build(extract_bothb)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothb <- as.data.frame(limits_bothb)
both_yminb <- limits_bothb$ymin
both_ymaxb <- limits_bothb$ymax
#reassign dataframes (just to be safe)
work_bothb <- wrfb_both
#fill in missing dates to smooth fits
work_bothb <- work_bothb %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothb <- work_bothb$date
#create a new smooth dataframe to layer
smooth_frame_bothb <- data.frame(date_vec_bothb, both_trendb, both_yminb, both_ymaxb)
#WRF B
#plot smooth frames
p_wrf_b <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothb, y = ~both_trendb,
data = smooth_frame_bothb,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb,
'</br> Median Log Copies: ', round(both_trendb, digits = 2)),
line = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothb, ymin = ~both_yminb, ymax = ~both_ymaxb,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxb, digits = 2),
'</br> Min Log Copies: ', round(both_yminb, digits = 2)),
name = "",
fillcolor = '#D95F02',
line = list(color = '#D95F02')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF B") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfb_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#D95F02', size = 6, opacity = 0.65))
p_wrf_b
save(p_wrf_b, file = "./plotly_objs/p_wrf_b.rda")
#**************************************WRF C PLOT********************************************** #add trendlines #extract data from geom_smooth # *********************************span 0.6*********************************** #*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothc <- ggplot(wrfc_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothc<<-..y..), method = "loess", color = '#E7298A',
span = 0.25, n = 842)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothc
## `geom_smooth()` using formula 'y ~ x'
fit_bothc
## [1] 12.04977 12.04314 12.03660 12.03017 12.02383 12.01759 12.01145 12.00540
## [9] 11.99945 11.99359 11.98783 11.98216 11.97658 11.97110 11.96572 11.96042
## [17] 11.95522 11.95011 11.94509 11.94017 11.93533 11.93059 11.92593 11.92137
## [25] 11.91689 11.91250 11.90820 11.90399 11.89987 11.89583 11.89188 11.88802
## [33] 11.88424 11.88055 11.87695 11.87343 11.86999 11.86664 11.86337 11.86019
## [41] 11.85708 11.85406 11.85113 11.84827 11.84550 11.84280 11.84019 11.83766
## [49] 11.83520 11.83283 11.83055 11.82839 11.82635 11.82443 11.82262 11.82092
## [57] 11.81934 11.81788 11.81652 11.81528 11.81415 11.81312 11.81221 11.81141
## [65] 11.81072 11.81013 11.80965 11.80927 11.80901 11.80884 11.80878 11.80883
## [73] 11.80897 11.80922 11.80957 11.81002 11.81057 11.81122 11.81196 11.81281
## [81] 11.81375 11.81479 11.81592 11.81715 11.81847 11.81988 11.82139 11.82299
## [89] 11.82468 11.82646 11.82833 11.83029 11.83234 11.83447 11.83669 11.83900
## [97] 11.84139 11.84387 11.84644 11.84910 11.85187 11.85477 11.85778 11.86091
## [105] 11.86416 11.86753 11.87102 11.87463 11.87837 11.88222 11.88620 11.89031
## [113] 11.89454 11.89890 11.90339 11.90800 11.91274 11.91762 11.92262 11.92775
## [121] 11.93302 11.93842 11.94396 11.94962 11.95543 11.96137 11.96745 11.97366
## [129] 11.98002 11.98651 11.99314 11.99992 12.00684 12.01390 12.02110 12.02976
## [137] 12.04100 12.05457 12.07020 12.08764 12.10663 12.12691 12.14823 12.17031
## [145] 12.19291 12.21577 12.23861 12.26120 12.28326 12.30454 12.32478 12.34373
## [153] 12.36111 12.37667 12.39016 12.40132 12.41212 12.42466 12.43878 12.45438
## [161] 12.47130 12.48944 12.50865 12.52881 12.54978 12.57144 12.59366 12.61631
## [169] 12.63925 12.66236 12.68551 12.70857 12.73140 12.75389 12.77589 12.79728
## [177] 12.81793 12.83771 12.85649 12.87414 12.89053 12.90553 12.91901 12.93084
## [185] 12.94089 12.94903 12.95513 12.95907 12.96070 12.95998 12.95700 12.95191
## [193] 12.94484 12.93594 12.92532 12.91314 12.89953 12.88461 12.86854 12.85144
## [201] 12.83346 12.81472 12.79537 12.77553 12.75535 12.73497 12.71451 12.69412
## [209] 12.67392 12.65407 12.63468 12.61591 12.59788 12.58073 12.56459 12.54961
## [217] 12.53592 12.52159 12.50473 12.48558 12.46437 12.44133 12.41669 12.39067
## [225] 12.36351 12.33543 12.30667 12.27746 12.24801 12.21857 12.18937 12.16062
## [233] 12.13256 12.10543 12.07944 12.05483 12.03183 12.01067 11.99157 11.97477
## [241] 11.95914 11.94340 11.92758 11.91169 11.89576 11.87981 11.86385 11.84791
## [249] 11.83201 11.81616 11.80039 11.78472 11.76916 11.75374 11.73847 11.72339
## [257] 11.70850 11.69383 11.67939 11.66521 11.65131 11.63792 11.62523 11.61321
## [265] 11.60180 11.59097 11.58068 11.57088 11.56152 11.55258 11.54399 11.53573
## [273] 11.52775 11.52001 11.51247 11.50507 11.49779 11.49058 11.48339 11.47618
## [281] 11.46892 11.46155 11.45404 11.44635 11.43842 11.43023 11.42172 11.41326
## [289] 11.40522 11.39757 11.39030 11.38337 11.37676 11.37045 11.36442 11.35863
## [297] 11.35307 11.34770 11.34251 11.33748 11.33257 11.32776 11.32303 11.31835
## [305] 11.31370 11.30906 11.30439 11.29969 11.29491 11.29004 11.28426 11.27688
## [313] 11.26803 11.25787 11.24654 11.23418 11.22096 11.20701 11.19248 11.17751
## [321] 11.16226 11.14687 11.13149 11.11626 11.10134 11.08686 11.07298 11.05984
## [329] 11.04759 11.03638 11.02635 11.01765 11.01043 11.00483 11.00100 10.99909
## [337] 10.99925 11.00073 11.00270 11.00515 11.00810 11.01153 11.01544 11.01985
## [345] 11.02474 11.03012 11.03599 11.04234 11.04918 11.05651 11.06432 11.07262
## [353] 11.08141 11.09068 11.10045 11.11069 11.12143 11.13377 11.14871 11.16606
## [361] 11.18564 11.20728 11.23078 11.25597 11.28267 11.31068 11.33984 11.36995
## [369] 11.40083 11.43231 11.46419 11.49630 11.52846 11.56048 11.59217 11.62337
## [377] 11.65388 11.68352 11.71211 11.73947 11.76541 11.78976 11.81233 11.83293
## [385] 11.85139 11.86976 11.89004 11.91200 11.93543 11.96009 11.98575 12.01218
## [393] 12.03915 12.06643 12.09380 12.12103 12.14788 12.17413 12.19955 12.22391
## [401] 12.24697 12.26852 12.28832 12.30614 12.32175 12.33493 12.34662 12.35792
## [409] 12.36882 12.37932 12.38943 12.39914 12.40845 12.41736 12.42587 12.43398
## [417] 12.44168 12.44898 12.45588 12.46237 12.46846 12.47413 12.47940 12.48426
## [425] 12.48871 12.49275 12.49638 12.49959 12.50238 12.50412 12.50422 12.50283
## [433] 12.50010 12.49614 12.49112 12.48515 12.47838 12.47095 12.46299 12.45465
## [441] 12.44605 12.43734 12.42866 12.42014 12.41192 12.40414 12.39693 12.39043
## [449] 12.38479 12.38013 12.37503 12.36803 12.35931 12.34900 12.33727 12.32427
## [457] 12.31014 12.29505 12.27915 12.26258 12.24551 12.22808 12.21045 12.19277
## [465] 12.17519 12.15787 12.14096 12.12461 12.10898 12.09422 12.08048 12.06792
## [473] 12.05668 12.04692 12.03880 12.03246 12.02653 12.01958 12.01174 12.00314
## [481] 11.99390 11.98415 11.97400 11.96359 11.95304 11.94246 11.93200 11.92176
## [489] 11.91188 11.90247 11.89367 11.88559 11.87837 11.87211 11.86696 11.86303
## [497] 11.86044 11.85933 11.85981 11.86208 11.86617 11.87195 11.87929 11.88807
## [505] 11.89816 11.90944 11.92177 11.93502 11.94908 11.96382 11.97910 11.99480
## [513] 12.01079 12.02695 12.04315 12.05926 12.07516 12.09071 12.10580 12.12029
## [521] 12.13405 12.14696 12.15890 12.16973 12.17933 12.18757 12.19432 12.20107
## [529] 12.20930 12.21887 12.22967 12.24155 12.25440 12.26808 12.28246 12.29742
## [537] 12.31282 12.32854 12.34446 12.36043 12.37633 12.39203 12.40741 12.42233
## [545] 12.43667 12.45030 12.46308 12.47489 12.48560 12.49509 12.50322 12.50986
## [553] 12.51488 12.51817 12.51958 12.51961 12.51886 12.51739 12.51523 12.51243
## [561] 12.50902 12.50505 12.50057 12.49561 12.49021 12.48443 12.47829 12.47186
## [569] 12.46516 12.45824 12.45114 12.44390 12.43657 12.42920 12.42181 12.41446
## [577] 12.40718 12.40003 12.39303 12.38624 12.37970 12.37191 12.36153 12.34879
## [585] 12.33393 12.31718 12.29878 12.27898 12.25800 12.23609 12.21349 12.19042
## [593] 12.16714 12.14388 12.12087 12.09835 12.07656 12.05575 12.03614 12.01797
## [601] 12.00149 11.98692 11.97452 11.96451 11.95523 11.94494 11.93373 11.92173
## [609] 11.90904 11.89576 11.88199 11.86786 11.85347 11.83891 11.82431 11.80977
## [617] 11.79539 11.78128 11.76756 11.75432 11.74167 11.72973 11.71860 11.70838
## [625] 11.69919 11.69113 11.68431 11.67883 11.67481 11.67235 11.67170 11.67293
## [633] 11.67589 11.68041 11.68634 11.69352 11.70179 11.71099 11.72097 11.73155
## [641] 11.74260 11.75393 11.76541 11.77687 11.78814 11.79908 11.80952 11.81930
## [649] 11.82827 11.83627 11.84313 11.85007 11.85833 11.86782 11.87844 11.89009
## [657] 11.90267 11.91608 11.93024 11.94503 11.96036 11.97614 11.99226 12.00863
## [665] 12.02515 12.04172 12.05825 12.07463 12.09077 12.10657 12.12194 12.13677
## [673] 12.15096 12.16443 12.17706 12.18877 12.19946 12.20902 12.21736 12.22513
## [681] 12.23301 12.24098 12.24902 12.25711 12.26523 12.27336 12.28148 12.28957
## [689] 12.29761 12.30556 12.31343 12.32117 12.32878 12.33624 12.34351 12.35058
## [697] 12.35743 12.36404 12.37038 12.37645 12.38220 12.38764 12.39261 12.39702
## [705] 12.40090 12.40431 12.40728 12.40984 12.41204 12.41391 12.41550 12.41684
## [713] 12.41797 12.41894 12.41978 12.42053 12.42123 12.42192 12.42263 12.42342
## [721] 12.42431 12.42534 12.42656 12.42801 12.42972 12.43173 12.43408 12.43682
## [729] 12.43978 12.44277 12.44578 12.44881 12.45183 12.45485 12.45784 12.46079
## [737] 12.46370 12.46656 12.46935 12.47206 12.47468 12.47720 12.47961 12.48189
## [745] 12.48405 12.48605 12.48790 12.48958 12.49109 12.49250 12.49392 12.49533
## [753] 12.49672 12.49809 12.49943 12.50073 12.50199 12.50318 12.50432 12.50538
## [761] 12.50636 12.50725 12.50804 12.50873 12.50931 12.50976 12.51008 12.51027
## [769] 12.51031 12.51019 12.50991 12.50947 12.50890 12.50829 12.50763 12.50691
## [777] 12.50614 12.50530 12.50440 12.50343 12.50239 12.50128 12.50010 12.49883
## [785] 12.49748 12.49605 12.49453 12.49291 12.49121 12.48941 12.48750 12.48550
## [793] 12.48339 12.48119 12.47894 12.47661 12.47423 12.47178 12.46925 12.46666
## [801] 12.46399 12.46125 12.45843 12.45554 12.45256 12.44950 12.44635 12.44312
## [809] 12.43980 12.43639 12.43289 12.42929 12.42560 12.42180 12.41791 12.41392
## [817] 12.40982 12.40562 12.40131 12.39689 12.39236 12.38771 12.38294 12.37805
## [825] 12.37305 12.36794 12.36272 12.35738 12.35194 12.34640 12.34076 12.33501
## [833] 12.32917 12.32323 12.31720 12.31108 12.30487 12.29857 12.29219 12.28572
## [841] 12.27918 12.27256
#assign fits to a vector
both_trendc <- fit_bothc
#extract y min and max for each
limits_bothc <- ggplot_build(extract_bothc)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothc <- as.data.frame(limits_bothc)
both_yminc <- limits_bothc$ymin
both_ymaxc <- limits_bothc$ymax
#reassign dataframes (just to be safe)
work_bothc <- wrfc_both
#fill in missing dates to smooth fits
work_bothc <- work_bothc %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothc <- work_bothc$date
#create a new smooth dataframe to layer
smooth_frame_bothc <- data.frame(date_vec_bothc, both_trendc, both_yminc, both_ymaxc)
#WRF C
#plot smooth frames
p_wrf_c <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothc, y = ~both_trendc,
data = smooth_frame_bothc,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc,
'</br> Median Log Copies: ', round(both_trendc, digits = 2)),
line = list(color = '#E7298A', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothc, ymin = ~both_yminc, ymax = ~both_ymaxc,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxc, digits = 2),
'</br> Min Log Copies: ', round(both_yminc, digits = 2)),
name = "",
fillcolor = '#E7298A',
line = list(color = '#E7298A')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF C") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfc_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#E7298A', size = 6, opacity = 0.65))
p_wrf_c
save(p_wrf_c, file = "./plotly_objs/p_wrf_c.rda")
save(wrfa_both, file = "./plotly_objs/wrfa_both.rda")
save(wrfb_both, file = "./plotly_objs/wrfb_both.rda")
save(wrfc_both, file = "./plotly_objs/wrfc_both.rda")
save(date_vec_botha, file = "./plotly_objs/date_vec_botha.rda")
save(date_vec_bothb, file = "./plotly_objs/date_vec_bothb.rda")
save(date_vec_bothc, file = "./plotly_objs/date_vec_bothc.rda")
save(both_ymina, file = "./plotly_objs/both_ymina.rda")
save(both_ymaxa, file = "./plotly_objs/both_ymaxa.rda")
save(both_yminb, file = "./plotly_objs/both_yminb.rda")
save(both_ymaxb, file = "./plotly_objs/both_ymaxb.rda")
save(both_yminc, file = "./plotly_objs/both_yminc.rda")
save(both_ymaxc, file = "./plotly_objs/both_ymaxc.rda")